package sword_to_1;

import node.ListNode;

import java.util.HashSet;
import java.util.Set;

public class LeeCode_52 {
    public static void main(String[] args) {

    }
    private static ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        Set<ListNode> set = new HashSet<>();
        while (headA != null){
            set.add(headA);
            headA = headA.next;
        }
        while (headB != null){
            if (set.contains(headB)){
                return headB;
            }
            headB = headB.next;
        }
        return null;
    }
}
